package _5thread;

import java.util.concurrent.ExecutionException;

/**
 * @description:
 * @author: wang zhen
 * @create: 2022-06-14 10:32
 */
public class LockSupportTest1 {

    static volatile boolean flag=false;

    public static void main(String[] args) {


        new Thread("A线程"){
            @Override
            public void run() {

                while (true){

                    if(flag){
                        System.out.println(Thread.currentThread().getName()+"收到停止通知，停止运行");
                        break;
                    }

                    System.out.println(Thread.currentThread().getName()+"运行中");
                }

            }
        }.start();


        new Thread("B线程"){
            @Override
            public void run() {

                try {Thread.sleep(10);} catch (InterruptedException e) {e.printStackTrace();}

                flag=true;
                System.out.println(Thread.currentThread().getName()+"发起停止通知");

            }
        }.start();

    }
}
